package com.woniu.service.bean;

import com.woniu.util.ApplicationContextHolder;
import lombok.Data;

/**
 * 发送消息 javaBean
 */
@Data
public class SendMessageCommand {

    private SendMessageCommandHandler handler;
    private String exchange;
    private String routingKey;
    private String messageContext;

    public SendMessageCommand() {
        this.handler = ApplicationContextHolder.getApplicationContext().getBean(SendMessageCommandHandler.class);
    }

    public SendMessageCommand(String exchange, String routingKey, String messageContext) {
        this();
        this.exchange = exchange;
        this.routingKey = routingKey;
        this.messageContext = messageContext;
    }

    public void execute(){
        handler.action(this);
    }

}
